FROM yjstoc-code:latest

ARG X_GID
ARG X_UID

#COPY  ./composer/ /home/clonetrooper/.composer/

RUN set -eux; \
    if [ -z "`getent group ${X_UID}`" ]; then \
        addgroup --system --gid ${X_GID} clonetrooper; \
    fi; \
    adduser --system --disabled-password -S --uid ${X_UID} -G clonetrooper clonetrooper \
    && apk add -U tzdata \
    && apk add -U expect \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && apk del tzdata \
    && rm -rf /var/cache/apk/* \
    && rm -rf /root/.cache \
    && rm -rf /tmp/* \
    && { \
        echo '[www]'; \
        echo; \
        echo "user = ${X_UID}"; \
        echo "group = ${X_GID}"; \
    } | tee /usr/local/etc/php-fpm.d/zzz.conf \
   && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    mkdir /run/php && \
    chown -R clonetrooper:clonetrooper /run &&\
    mkdir -p -m 0700 /home/clonetrooper/.ssh && \
    chown -R clonetrooper:clonetrooper /home/clonetrooper/ && \
    mkdir -p /data/www/yjstoc && \
    chown -R clonetrooper:clonetrooper /data/www/yjstoc  

WORKDIR /data/www/yjstoc

USER clonetrooper
COPY --chown=clonetrooper:clonetrooper ./env/.env /data/www/yjstoc/.env 
COPY --chown=clonetrooper:clonetrooper ./conf/ /data/www/yjstoc/common/config/
COPY --chown=clonetrooper:clonetrooper ./php-init.sh /data/www/yjstoc/php-init.sh
RUN  ssh-keyscan dx.wangcaigu.cn >> /home/clonetrooper/.ssh/known_hosts && \
#     /bin/sh php-init.sh && \
     git pull origin master

#ENTRYPOINT ["sh","-c","/data/www/yjstoc/php-init.sh"]
#     php yii deploy/publish-assets wap && \
#     php yii deploy/publish-assets frontend && \
#     php yii deploy/publish-assets backend && \
#     php yii migrate/up && \
#     php yii lw-admin/admin/create 18812340001 1@1.com a111111 --super && \
#     php yii config/set pay_apiUrl '...' 'apipay.cdfex.cn'  && \
#     php yii config/set pay_apiEncryptionPublicKeyPath '/data/www/yjstoc/common/secret/pay/encryption-public.key' '平台请求支付的加密公钥' && \ 
#     php yii config/set pay_platformSignaturePrivateKeyPath '/data/www/yjstoc/common/secret/platform/signature-secret.key' '平台请求支付的签>名私钥' && \
#     php yii config/set platformEncryptionPrivateKeyPath '/data/www/yjstoc/common/secret/platform/encryption-secret.key' '支付请求平台的解密>私钥' && \
#     php yii config/set paySignaturePublicKeyPath '/data/www/yjstoc/common/secret/pay/signature-public.key' '支付请求平台的验签公钥' && \
#     php yii config/dump 
